using System.Linq;
using Dgg.Anug.Cqrs.Core.Presentation.Models.Admin;
using Raven.Client.Indexes;
using Raven.Database.Indexing;

namespace Dgg.Anug.Cqrs.Core.Application.Admin.Queries
{
	public class BuildsAssignedToSolution : AbstractIndexCreationTask
	{
		public override IndexDefinition CreateIndexDefinition()
		{
			return new IndexDefinition<Build>
			{
				Map = Builds =>
					from build in Builds
					where build.AssignedTo != null
					select new { build.AssignedTo.Id }
			}.ToIndexDefinition(DocumentStore.Conventions);
		}
	}
}